package com.csair.platform.cit.service.feignclient.usercenter;

import com.csair.invoice.common.base.vo.JsonResult;
import com.csair.platform.usercenter.facade.model.user.UserQueryParams;
import com.csair.platform.usercenter.facade.model.user.UserVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * rest服务调用的客户端
 * 直接注入本接口，即可使用
 * url="http://10.108.52.18:9091/"
 * 通过url指定服务提供方是谁
 *
 * @author liaoxiaojin
 */
@FeignClient(name = "usercenter", url = "${user.api.url}")
public interface UserFeignClient {

    /**
     * 获取用户信息
     *
     * @param queryParam 请求报文
     * @return 响应报文
     */
    @PostMapping(value = "/user/findByParam")
    JsonResult<UserVo> findByParam(@RequestBody UserQueryParams queryParam);

    /**
     * 从缓存中获取用户信息
     *
     * @param token 用户token
     * @return 响应报文
     */
    @PostMapping(value = "/user/cache/getUserFromCache")
    JsonResult<UserVo> getUserFromCache(@RequestParam("token") String token);

    /**
     * 批量获取用户信息
     *
     * @param body 必须含有ids字段
     * @return
     */
    @PostMapping(value = "/user/findByIds")
    JsonResult<UserVo> findByIds(@RequestBody Map<String, Object> body);

    @PostMapping(value="/user/listAll")
    JsonResult<UserVo> list();

}
